import { useModel } from "umi";

const userCheckPositionNameNoSelf = () => {
    const { graphqlFetch } = useModel("global");

    const checkPositionNameNoSelf = async (variables) => {
        let res = await graphqlFetch({
            query: `query MyQuery($opName: String!, $notEqualTo: UUID!) { a: allOrganizationPositions(condition: { opName: $opName }, filter: { opUuid: { notEqualTo: $notEqualTo } }) { totalCount } }`,
            variables,
        });
        return res ? res.a.totalCount : null;
    };

    return { checkPositionNameNoSelf };
};

export default userCheckPositionNameNoSelf;
